Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chain Agnostic MultiNode Adaptor #957

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

DylanTinianov
Copy link
Contributor

@DylanTinianov DylanTinianov commented Dec 3, 2024

Description

Ticket: https://smartcontract-it.atlassian.net/browse/BCFR-1071

Most of the code in the Solana MultiNodeClient can be reused by all chain integrations. This PR extracts all of the chain-agnostic client code through making a generic MultiNodeClient. This will further extract functionality into the MultiNode and reduce new integration cost.

Generic MultiNodeClient:

type MultiNodeAdaptor[RPC any, HEAD Head] struct {
	cfg         *mnCfg.MultiNodeConfig
	rpc         *RPC
	stateMu     sync.RWMutex // protects state* fields
	subsSliceMu sync.RWMutex
	subs        map[Subscription]struct{}
    chStopInFlight chan struct{}
	chainInfoLock sync.RWMutex
	highestUserObservations ChainInfo
	latestChainInfo ChainInfo
	
	// chain-specific functions will be passed in
	latestBlock          func(ctx context.Context, rpc *RPC) (HEAD, error)
	latestFinalizedBlock func(ctx context.Context, rpc *RPC) (HEAD, error)
}

The the following methods can all be chain-agnostic and extracted:

RegisterSub(sub Subscription, stopInFLightCh chan struct{}) 
LatestBlock(ctx context.Context) (HEAD, error) 
LatestFinalizedBlock(ctx context.Context) (HEAD, error) 
SubscribeToHeads
SubscribeToFinalizedHeads
OnNewHead
OnNewFinalizedHead
MakeQueryCtx
AcquireQueryCtx
UnsubscribeAllExcept
CancelInflightRequests
Close
GetInterceptedChainInfo

All other client methods will still be implemented on the chain specific side including:

Dial(ctx context.Context) error 
IsSyncing()
Ping(ctx context.Context) 
SendTxResult

Soak Tests

Namespace solana-gauntlet-embedded-f0856
Using 3 RPS on Solana Devnet

@DylanTinianov DylanTinianov changed the title Generic MultiNodeClient Chain Agnostic MultiNodeClient Dec 3, 2024
@DylanTinianov DylanTinianov marked this pull request as ready for review December 3, 2024 17:14
@DylanTinianov DylanTinianov requested a review from a team as a code owner December 3, 2024 17:14
@DylanTinianov DylanTinianov changed the title Chain Agnostic MultiNodeClient Chain Agnostic MultiNode Adaptor Dec 11, 2024
@DylanTinianov
Copy link
Contributor Author

It would be nice to have a corresponding PR for EVM before we merge this to ensure that everything aligns.

@dhaidashenko I'm running a soak test for Solana, and then I plan on adding this to chainlink-framework. After I will soak test this on EVM while extracting EVM to use chainlink-framework.

@cl-sonarqube-production
Copy link

Quality Gate failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 75%)

See analysis details on SonarQube

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants